import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2022-05-20
 * Time: 11:21
 */
public class Main {
    public static void main(String[] args) {
        String x = "ab##";
        String y = "c#d#";
        System.out.println(backspaceCompare(x, y));
    }
    public static boolean backspaceCompare(String s, String t) {
        if(s.equals("#") || t.equals("#")) return false;

        String x = null;
        for(int i = 0 ; i < s.length();i++) {
            if(s.charAt(i) == '#') {
                char ch =  s.charAt(i-1);
                s = s.replace(ch+"#","");
                i = 0;
            }
        }
        String y = null;
        for(int i = 0 ; i < t.length()+1;i++) {
            if(t.charAt(i) == '#') {
                char ch =  t.charAt(i-1);
                 t = t.replace(ch+"#","");
                 i = 0;
            }
        }
        if(s.equals(t)) {
            return true;
        }
        return false;
    }
   /* public int evalRPN(String[] tokens) {
        Stack<Integer> stack = new Stack<>();

        for(int i = 0 ; i < tokens.length;i++) {
            String x = tokens[i];
            if(!isBool(x)) {
                stack.push(Integer.valueOf(x));
            }else {
                if(stack.isEmpty()) {
                    break;
                }else {
                    int sum = 0;
                    int num1 = stack.pop();
                    int num2 = stack.pop();
                    switch(x) {
                        case "+":
                            sum = num1 + num2;
                            stack.push(sum);
                            break;
                        case "-":
                            sum = num1 - num2;
                            stack.push(sum);
                            break;
                        case "*":
                            sum = num1 * num2;
                            stack.push(sum);
                            break;
                        case "/":
                            sum = num1 / num2;
                            stack.push(sum);
                            break;
                    }
                }
            }
        }
        return stack.pop();
    }*/
    public List<List<Integer>> shiftGrid(int[][] grid, int k) {
        List<List<Integer>> ret = new ArrayList<>();
        int m = grid.length;
        int n = grid[m].length;
        while(k > 0) {
            for(int i = 0;i < m;i++) {
                for(int j = 0; j < n;j++) {
                    if(i == m-1&&n==n-1) {

                    }
                }
            }
            k--;
        }
        return ret;
    }
}
